package com.carl.creatThread;


/**
 * 实现Runnable接口 重写run方法
 */
public class MyTest_2_2 {

    public static void main(String[] args) {
//        MyRunnable myRunnable = new MyRunnable();
//        new Thread(myRunnable).start();
//        for (int i = 0; i < 100; i++) {
//            System.out.println("main" + i);
//        }


        /*
         * 匿名内部类
         */
        Thread t1 =  new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println("MyRunnable:" + i);
                }
            }
        });
        t1.start();

        /*
        lambda表达式
         */
        Thread t2 = new Thread(()->{
            for (int i = 0; i < 100; i++) {
                System.out.println("MyRunnable2:" + i);
            }
        });
        t2.start();

    }




}


//class MyRunnable implements Runnable{
//    @Override
//    public void run() {
//        for (int i = 0; i < 100; i++) {
//            System.out.println("MyRunnable:" + i);
//        }
//    }

